<template>
  <div>
    <CloudSwitch :checked="!loading" @change="onChange" />

    <CloudList item-layout="vertical" size="large" :data-source="listData">
      <CloudListItem slot="renderItem" key="item.title" slot-scope="item, index">
        <template v-for="{ type, text } in actions" v-if="!loading" slot="actions">
          <span :key="type">
            <CloudIcon :type="type" style="margin-right: 8px" />
            {{ text }}
          </span>
        </template>
        <img
          v-if="!loading"
          slot="extra"
          width="272"
          alt="logo"
          src="https://gw.alipayobjects.com/zos/rmsportal/mqaQswcyDLcXyDKnZfES.png"
        />
        <CloudSkeleton :loading="loading" active avatar>
          <CloudListItemMeta :description="item.description">
            <a slot="title" :href="item.href">{{ item.title }}</a>
            <CloudAvatar slot="avatar" :src="item.avatar" />
          </CloudListItemMeta>
          {{ item.content }}
        </CloudSkeleton>
      </CloudListItem>
    </CloudList>
  </div>
</template>
<script>
const listData = [];
for (let i = 0; i < 3; i++) {
  listData.push({
    href: 'https://www.antdv.com/',
    title: `ant design vue part ${i}`,
    avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
    description:
      'Ant Design, a design language for background applications, is refined by Ant UED Team.',
    content:
      'We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.',
  });
}
export default {
  title: '5.列表',
  data() {
    return {
      loading: true,
      listData,
      actions: [
        { type: 'star-o', text: '156' },
        { type: 'like-o', text: '156' },
        { type: 'message', text: '2' },
      ],
    };
  },
  methods: {
    onChange(checked) {
      this.loading = !checked;
    },
  },
};
</script>
<style>
.skeleton-demo {
  border: 1px solid #f4f4f4;
}
</style>